<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <title>签约确认</title>
    <%- include('./_global/baseLibsYs') %>
    <link rel="stylesheet" href="/static/css/qyjm/page.css"/>
    <link rel="stylesheet" href="/static/css/mycontract.css"/>
    <link rel="stylesheet" href="/static/css/qyjm/public.css"/>
    <style>

        body {
            background: white;
            font-family: "Helvetica Neue", Helvetica, STHeiTi, Arial, Microsoft YaHei, sans-serif;
        }

        a:link, a:visited {
            text-decoration: none; /*超链接无下划线*/
        }

        a:hover {
            text-decoration: none; /*鼠标放上去有下划线*/
        }

        .qy-message-list ul {
            margin-top: 5px;
        }

        .qyls-box2 ul > li > .qyls-a1 {
            bottom: 0.80952rem;
            width: 5.47619rem;
            height: 2.04762rem;
            line-height: 2.04762rem;
            border: 1px solid #087cff;
            color: #fff;
            font-size: 1.14286rem;
            position: absolute;
            right: 7.95238rem;
            text-align: center;
            border-radius: 6px;
            background: #087cff;
            cursor: pointer;
        }

        .qyls-box2 ul > li > .qyls-a2 {
            bottom: 0.80952rem;
            width: 5.47619rem;
            height: 2.04762rem;
            line-height: 2.04762rem;
            border: 1px solid #087cff;
            color: #087cff;
            font-size: 1.14286rem;
            position: absolute;
            right: 0.95238rem;
            text-align: center;
            border-radius: 6px;
            cursor: pointer;
        }

        .qyls-box2 ul > li {
            padding: 0rem 0rem 1.33333rem 0rem !important;
        }

        .row1 {
            display: inline !important;
        }

        .qyzt1 {
            border: 1px solid #1CA261 !important;
            color: #1CA261 !important;
        }

        .qyzt2 {
            border: 1px solid #C0C0C0 !important;
            color: #C0C0C0 !important;
        }

    </style>
</head>
<body>

<header class="header-box grey fixed">
    <div class="header-content">
        <div class="left-tool">
            <a class="back" href="javascript:void(0);"><i class="iconfont icon-back"></i></a>
        </div>
        <div class="title">签约确认</div>
    </div>
</header>
<div class="hz-banner" id="hz">
    <img class="img-bg" src="/static/images/hzgl/hz-bg.png">
    <div class="hz-info-box">
        <div class="hz-photo"><img class="hzxx" id="PHOTO" src="/static/images/hzgl/hz-photo.png"></div>
        <div class="hz-message">
            <span class="first-message hzxx" id="xm"></span>
            <span class="right-message hzxx" id="XB"></span>
            <span class="right-message hzxx" id="NL"></span>
            <span class="second-message">身份证号: <span class="hzxx" id="ZJHM"></span></span>
            <span class="second-message">联系电话: <span class="hzxx" id="DHHM"></span></span>
        </div>
    </div>
</div>

<div class="qyls-box2" style="background: #fff;">
    <ul id="boxId"></ul>
</div>


<script type="text/html" id="module">
    <li>
        <i class="icon1"></i>
        <div class="qyls-span-box">
            <span class="blue-span" name="TDMC">李晓华签约服务团队 </span>
            <span>
			<span class="row1">签约时间：</span><span name="TJSJ" class="row1"></span>
		</span>
            <span style="padding-bottom: 30px;">
			<span style="float:left">套餐信息：</span>
			<span  name="fwtcBox"></span>
		</span>
        </div>
        <a class="qyls-a1" name="qrqy">确认签约</a>
        <a class="qyls-a2" name="jjqy">拒绝签约</a>
    </li>
</script>
<script>


    var page_qyqr = (function($, page_qyqr) {
        var actionDoc = null;  //用于删除
        var qyfwUserId = StoreCache.getCache("qyfwUserId");


        function initData() {
            var ysHzInfo = StoreCache.getCache("ysdHzInfo");
            $("#xm").html(ysHzInfo.XM);
            $("#ZJHM").html(ysHzInfo.ZJHM);
            $("#DHHM").html(ysHzInfo.SJHM);
            $("#NL").html(ysHzInfo.age);
            $("#XB").html(ysHzInfo.xb);
        }


        /**查询当前用户所有的签约信息*/
        function queryQyls() {
            var QYFW_HZXX = StoreCache.getCache("ysdHzInfo");
            var jmxxid = QYFW_HZXX.JMXXID;
            var queryParams = {
                USERID:qyfwUserId,
                JMXXID: jmxxid,
                qylxIn: "00",
                pageSize: 20,
                pageNumber: 1
            };
            $.QuickRemote.AjaxJson("api/doctor/qyfw/queryQyHistoryToJkcs", page_qyqr.queryDataBack, queryParams);
        }

        /** 查询数据回调  */
        function queryDataBack(result) {
            if (result.rows) {
                var data = result.rows;
                var total = 0;
                var box = $("#boxId");
                for (var i = 0; i < data.length; i++) {
                    var item = data[i];
                    var module = $($("#module").html());
                    module.find("[name=TDMC]").html(item.TDMC);
                    module.find("[name=TJSJ]").html(item.QYSJ);
                    module.find("[name=qrqy]").data(item).on("click", function () {
                        var QYXXID = $(this).data("QYXXID");
                        actionDoc = this;
                        page_qyqr.qyjmQrqy(QYXXID);
                    });
                    module.find("[name=jjqy]").data(item).on("click", function () {
                        var QYXXID = $(this).data("QYXXID");
                        actionDoc = this;
                        page_qyqr.qyjmJjqy(QYXXID);
                    });

                    var p = $("<span>").html(item.FWMCS);//模型   ==>  <p>护理服务套餐   3月</p>
                    module.find("[name=fwtcBox]").append(p);

                    total = 0;
                    box.append(module)
                }
            }
        }

        /** 确认签约 */
        function qyjmQrqy(QYXXID) {
            $.QuickRemote.AjaxJson("/api/doctor/qyfw/checkYqyData", page_qyqr.actionResult, {
                qyxxid: QYXXID,
                type: "agree"
            }, {successMsg: "签约成功！"});
        }

        /** 拒绝签约 */
        function qyjmJjqy(QYXXID) {
            $.QuickRemote.AjaxJson("api/doctor/qyfw/checkYqyData", page_qyqr.actionResult, {
                qyxxid: QYXXID,
                type: "noagree"
            }, {successMsg: "拒签成功！"});
        }

        function actionResult(result, parame) {
            if (result.state == "true"||result.state == true) {
                $.QuickAlert.alertNormal(parame.successMsg, {
                    callback: function () {
                        if ($("#boxId>li").length > 1) {
                            $(actionDoc).parent().remove();
                            StoreCache.setCache("clickBtnIndex", "2");
                            var url={refreshUrl:"/html/ysd/qyjm/qyjm_index.html",pageUrl:"/html/ysd/qyjm/qyjm_index.html"}
                            $.QuickUrlUtils.refreshJSBridge(url);
                            $.QuickUrlUtils.rebackJSBridge({url:"/html/ysd/qyjm/qyjm_index.html",title:"签约居民"});
//                           $.QuickUrlUtils.forward("/html/ysd/qyjm/qyjm_index.html", "签约居民");
                        } else {
                            StoreCache.setCache("clickBtnIndex", "2");
                            var url={refreshUrl:"/html/ysd/qyjm/qyjm_index.html",pageUrl:"/html/ysd/qyjm/qyjm_index.html"}
                            $.QuickUrlUtils.refreshJSBridge(url);
                            $.QuickUrlUtils.rebackJSBridge({url:"/html/ysd/qyjm/qyjm_index.html",title:"签约居民"});
//                           $.QuickUrlUtils.forward("/html/ysd/qyjm/qyjm_index.html", "签约居民");
                        }
                    }
                });
            } else {
                $.QuickAlert.alertFail({content: "提交失败，请稍候再试.."});
            }
        }

        var cfg_def = {
            initData: initData,
            queryQyls: queryQyls,
            queryDataBack: queryDataBack,
            qyjmQrqy: qyjmQrqy,
            qyjmJjqy: qyjmJjqy,
            actionResult: actionResult,
        }

        page_qyqr.init = function(cfg){
            $.extend(page_qyqr, cfg_def, cfg);
            page_qyqr.initData();
            page_qyqr.queryQyls();

        }

        return page_qyqr;
    })(jQuery, {});
    

</script>

</body>
</html>
